<div ng-drag="{{item.$$showEdit&&item.subDepartments.length==0?true:false}}" ng-drag-data="item" class="{{item.subDepartments.length>0?'tree-folder':'tree-item'}}" style="border: hidden" ng-init="showDetail=true;item.$$showEdit=(item.name!=undefined&&item.name!='')?false:true;showButton=false" ng-mouseover="item.subDepartments.length>0?a=a:showButton=true" ng-mouseleave="item.subDepartments.length>0?a=a:showButton=false">
    <div ng-if="item.subDepartments.length>0" >
    <div ng-drag="true" ng-drag-data="item" ng-mouseover="showButton=true" ng-mouseleave="showButton=false" class="tree-folder-header" style="border: hidden">
        <i class="fa fa-plus" ng-show="!showDetail" ng-click="$parent.showDetail=!showDetail"></i>
        <i class="fa fa-minus" ng-show="showDetail" ng-click="$parent.showDetail=!showDetail"></i>
        <div class="tree-folder-name" style="border: hidden">
            {{item.name}}:{{item.duty}}&nbsp;&nbsp;
            <div ng-show="showButton" style="display: inline">
                <i class="fa fa-edit" ng-click="item.$$showEdit=!item.$$showEdit"></i>&nbsp;&nbsp;
                 <i class="fa fa-plus-square-o"  ng-click="item.name==''||item.name==undefined?a=a:addFunction({array:item.subDepartments})" data-toggle="tooltip" title="{{item.name==''||item.name==undefined?'具有名称的部门才可以创建子部门':'创建一个子部门'}}"></i>&nbsp;&nbsp;
                <i class="fa  fa-minus-square-o" ng-click="deleteFunction({array:rep,index:$index})" data-toggle="tooltip" title="删除此部门"></i>
            </div>
        </div>
    </div>
    <div ng-show="item.$$showEdit" class="tree-folder-content" style="padding-left:20px">
        <div style="border: hidden" class="tree-item-name">
            <div class="row">
                <div class="col-md-1" style="padding-right: 0;padding-left: 0;margin-right: -15px">
                    部门名称:
                </div>
                <div class="col-md-5">
                    <input type="text" class="form-control" ng-model="item.name" ng-change="dirtySet({index:blockname})" placeholder="必填">
                </div>
            </div>
            <div class="row">
                <div class="col-md-1" style="padding-right: 0;padding-left: 0;margin-right: -15px">
                    部门职责:
                </div>
                <div class="col-md-5">
                    <input type="text" class="form-control" ng-model="item.duty" ng-change="dirtySet({index:blockname})">
                </div>
            </div>
        </div>
    </div>
    <div ng-show="showDetail" ng-init="rep=item.subDepartments" class="tree-folder-content" style="border: hidden">
        <div ng-repeat="item in rep" ng-include="template" style="border: hidden">
        </div>
    </div>
    </div>
    <div ng-if="item.subDepartments.length==0">
    <div style="border: hidden"  class="tree-item-name">
        <i class="fa fa-circle-o"></i>
        {{item.name}}:{{item.duty}}&nbsp;&nbsp;
        <div ng-show="showButton" style="display: inline">
            <i class="fa fa-edit" ng-click="item.$$showEdit=!item.$$showEdit"></i>&nbsp;&nbsp;
            <i class="fa fa-plus-square-o" ng-click="item.name==''||item.name==undefined?a=a:addFunction({array:item.subDepartments})" data-toggle="tooltip" title="{{item.name==''||item.name==undefined?'具有名称的部门才可以创建子部门':'创建一个子部门'}}"></i>&nbsp;&nbsp;
            <i class="fa  fa-minus-square-o" ng-click="deleteFunction({array:rep,index:$index})" data-toggle="tooltip" title="删除此部门"></i>&nbsp;&nbsp;
        </div>
    </div>
    <div  ng-show="item.$$showEdit" class="tree-folder-content" style="padding-left:20px">
        <div style="border: hidden" class="tree-item-name">
            <div class="row">
                <div class="col-md-1" style="padding-right: 0;padding-left: 0;margin-right: -15px">
                    部门名称:
                </div>
                <div class="col-md-5">
                    <input type="text" class="form-control" ng-model="item.name" ng-change="dirtySet({index:blockname})" placeholder="必填">
                </div>
            </div>
            <div class="row">
                <div class="col-md-1" style="padding-right: 0;padding-left: 0;margin-right: -15px">
                    部门职责:
                </div>
                <div class="col-md-5">
                    <input type="text" class="form-control" ng-model="item.duty" ng-change="dirtySet({index:blockname})">
                </div>
            </div>
        </div>
    </div>
    </div>
</div>